## -*- makefile -*- ###########################################################
#                                                                             #
#  Configuration stuff. You can change what is here as you wish. Just try to  #
#  make sense with all you write ;)                                           #
#                                                                             #
#  DEBUG=1       : Build a debugging library and/or examples                  #
#  PROFILE=1     : Build a profiling library and/or examples                  #
#                                                                             #
#  If you define both PROFILE and DEBUG, the last one will be used (make      #
#  PROFILE=1 DEBUG=1 will build a debugging library).                         #
#                                                                             #
#  KQ_CHEATS=1   : Compile extra cheat code for testing only                  #
#  KQ_USE_JGMOD  : Use JGMOD for music, otherwise use DUMB                    #
#  KQ_USE_2XSAI  : Use 2xSAI to smooth the stretched screen (prob won't       #
#                                                            work)            #
#  ReyBrujo, 2002                                                             #
#                                                                             #
#  17-Sep-2002 (PH) Added cheat mode, tested on Linux, added script makefile  #
#                                                                             #
###############################################################################


#                                                                             #
#  Basic package information.                                                 #
#                                                                             #
ID_SHORT := kq
MAJOR    := 0
MINOR    := 98
VERSION  := $(MAJOR).$(MINOR)
ID_LONG  := $(ID_SHORT)-$(VERSION)

#                                                                             #
#  Set the different programs we will be using. You must supply them all if   #
#  you have access to them. I think UPX (executable compressor) and GPP are   #
#  the only ones that might bring problems. If you don't have UPX, set it to  #
#  nothing.                                                                   #
#  GPP is the preprocessor program. It usually switches between 'gpp' and     #
#  'cpp'.                                                                     #
#  If you have pkzip rather than zip (traitor!) configure the variables to    #
#  match the executable and its flags.                                        #
#                                                                             #
GCC    := gcc
CC     := gcc
GPP    := cpp
MAKE   := make
RANLIB := ranlib
AR     := ar
UPX    := upx
ZIP    := zip
TGZ    := tar
RM     := rm


#                                                                             #
#  Directory names. You should not change them unless you change their names  #
#  (why you would do something like that? ;)                                  #
#                                                                             #
SRC_DIR := src
OBJ_DIR := obj
BIN_DIR := bin
DOC_DIR := docs
MAK_DIR := mkfiles
INC_DIR := include
SCR_DIR := scripts



#                                                                             #
#  Default flags. CFLAGS are the compilation flags for C. CXXFLAGS are used   #
#  for C++ compilation. LDFLAGS are the library flags, which should be empty  #
#  now (unless you need to link your executable with another library).        #
#  TGZFLAGS are passed as flags to your TGZ executable, and the ZIPFLAGS...   #
#  guess!                                                                     #
#  DFLAGS are the flags used to build the dependencies.                       #
#                                                                             #
CXXFLAGS := -Wall -Werror -W -I $(INC_DIR) -finline
CFLAGS   := -Wall -W -I $(INC_DIR)
DEPFLAGS := -MM -MG -I$(INC_DIR)
LDFLAGS  :=
TGZFLAGS := cvzf
ZIPFLAGS := -r -v
RMFLAGS  := -rf

ifdef KQ_CHEATS
	CFLAGS += -DKQ_CHEATS
endif

ifdef KQ_USE_JGMOD
	CFLAGS += -DKQ_USE_JGMOD
else
	CFLAGS += -DKQ_USE_DUMB
endif

ifdef KQ_USE_2XSAI
	CFLAGS += -DKQ_USE_2XSAI
endif


#                                                                             #
#  The extra libraries we need to compile the program. Just the base name.    #
#                                                                             #
LIBRARY  := lua
ifdef KQ_USE_JGMOD
	LIBRARY += jgmod
else
	LIBRARY += aldmb dumb
endif

ifdef KQ_USE_2XSAI
	LIBRARY += 2xsai
endif



#                                                                             #
#  Default extensions. The EXE_SUFFIX needs the dot ('.') as well.            #
#                                                                             #
EXE_SUFFIX := .exe
SRC_SUFFIX := c
OBJ_SUFFIX := o



#                                                                            #
#  By default, all the files found in the SRC_DIR directory and matching     #
#  the SRC_SUFFIX suffix are compiled.                                       #
#                                                                            #
#FILES := $(notdir $(basename $(wildcard $(SRC_DIR)/*.$(SRC_SUFFIX))))

# Use these explicit files:
FILES = combat.c effects.c eskill.c intrface.c masmenu.c scrnshot.c shopmenu.c\
	credits.c enemyc.c fade.c itemmenu.c menu.c selector.c timing.c\
	disk.c entity.c heroc.c kq.c music.c setup.c\
	draw.c eqpmenu.c hskill.c magic.c res.c sgame.c\
	movement.c $(EXTRAFILES)

#                                                                             #
#  Finally, add to the standard flags the options, according to the type of   #
#  linking we are looking for.                                                #
#                                                                             #
ifdef DEBUG
	CXXFLAGS += -g3 -ggdb3 -gstabs3 -DDEBUGMODE
	CFLAGS   += -g3 -ggdb3 -gstabs3 -DDEBUGMODE
	LDFLAGS  += -g3 -ggdb3 -gstabs3 -DDEBUGMODE
	ALLEGRO = alld
else
	ifdef PROFILE
		CXXFLAGS += -pg -finline-functions -Winline
		CFLAGS   += -pg
		LDFLAGS  += -pg
		ALLEGRO  = allp
	else
		LDFLAGS  += -s
		CFLAGS   += -O2
		ALLEGRO  = alleg
	endif
endif

#
# Main target: (this comes here so we know it's the first target)
#
all: game scripting editor

